package com.hebang.stcommunityapp.activitys;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.hebang.stcommunityapp.LoginActivity;
import com.hebang.stcommunityapp.R;
import com.hebang.stcommunityapp.adapters.DeviceListdapter;
import com.hebang.stcommunityapp.adapters.SyListdapter;
import com.hebang.stcommunityapp.beans.SyItemBean;
import com.hebang.stcommunityapp.databinding.ActivityDeviceManagBinding;

import java.util.ArrayList;

public class DeviceManagActivity extends AppCompatActivity {
    ActivityDeviceManagBinding binding;
    DeviceListdapter adapter;
    RecyclerView recyclerview;
    private ArrayList<SyItemBean> list = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().hide();
        binding = DataBindingUtil.setContentView(this, R.layout.activity_device_manag);
        initdata();
        initRecycler();
    }

    private void initRecycler() {
        if (adapter == null) {
            recyclerview = binding.statutefragmentRecyclerview;
            GridLayoutManager layoutManager = new GridLayoutManager(DeviceManagActivity.this, 1);
            recyclerview.setLayoutManager(layoutManager);
            adapter = new DeviceListdapter(list);
            recyclerview.setAdapter(adapter);
            adapter.setOnItemClickListener(new DeviceListdapter.OnItemClickListener() {
                @Override
                public void onClick(View view, int position) {
                    Intent intent = new Intent(DeviceManagActivity.this, DeviceDetActivity.class);
                    startActivity(intent);

                }
            });
        } else {
            adapter.notifyDataSetChanged();
        }
    }


    private void initdata() {
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());
        list.add(new SyItemBean());

    }
}